<?php

namespace LowCode\Support;

use LowCode\Traits\HasMake;

/**
 * @method static $this make(JsFn|JsExp $source, JsFn $handler, array $options = [])
 */
class JsWatch extends Fluent
{
    use HasMake;
    /**
     * @param JsFn|JsExp $source
     * @param JsFn $handler
     * @param array $options
     */
    public function __construct(JsFn|JsExp $source, JsFn $handler, array $options = [])
    {
        parent::__construct([
            "source"=>$source,
            "handler"=>$handler,
            ...$options
        ]);
    }

    /**
     * @param string $id
     * @return $this
     */
    public function id(string $id): static
    {
        return $this->setAttribute("id", $id);
    }

    /**
     * @param bool $bool
     * @return $this
     */
    public function deep(bool $bool): static
    {
        return $this->setAttribute("deep", $bool);
    }

    /**
     * @param bool $bool
     * @return $this
     */
    public function immediate(bool $bool): static
    {
        return $this->setAttribute("immediate", $bool);
    }
}
